﻿namespace Beehive_Management_System
{
    class Worker : Bee
    {
        public Worker(string[] job, int weidth) : base(weidth)
        {
            jobsICanDo = job;
        }

        public string CurrentJob {get; private set; }

        public override int ShiftsLeft
        {
            get { return shiftsToWorks - shiftsWorked; }
        }

        private readonly string[] jobsICanDo;
        private int shiftsToWorks;
        private int shiftsWorked;

        public bool DoThisJob(string job, int numberOfShift)
        {
            if (!string.IsNullOrEmpty(CurrentJob))
            {
                return false;
            }

            for (int i = 0; i < jobsICanDo.Length; i++)
            {
                if (jobsICanDo[i] == job)
                {
                    CurrentJob = job;
                    shiftsToWorks = numberOfShift;
                    shiftsWorked = 0;
                    return true;
                }
            }

            return false;
        }

        public bool WorkOneShift()
        {
            if (string.IsNullOrEmpty(CurrentJob))
            {
                return false;
            }
            shiftsWorked++;
            if (shiftsWorked > shiftsToWorks)
            {
                shiftsWorked = 0;
                shiftsToWorks = 0;
                CurrentJob = "";
                return true;
            }
            else
            {
                return false; 
            }
        }
    }
}
